package com.tianji.learning.controller;


import com.tianji.common.domain.dto.PageDTO;
import com.tianji.learning.domain.po.QuestionFormDTO;
import com.tianji.learning.domain.po.QuestionPageQuery;
import com.tianji.learning.domain.vo.QuestionVO;
import com.tianji.learning.service.IInteractionQuestionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 互动提问的问题表 前端控制器
 * </p>
 *
 * @author author
 * @since 2024-12-18
 */
@RestController("interactionQuestionController")
@RequestMapping("/questions")
@Api(tags = "互动提问的问题相关接口")
public class InteractionQuestionController {
    @Autowired
    private IInteractionQuestionService questionService;

    @PostMapping
    @ApiOperation("新增互动提问的问题")
    public void addQuestion(@RequestBody QuestionFormDTO dto) {
        questionService.addQuestion(dto);
    }

    @PutMapping("/{id}")
    @ApiOperation("修改互动提问的问题")
    public void updateQuestion(@PathVariable("id") Long id,@RequestBody QuestionFormDTO dto) {
        questionService.updateQuestion(id,dto);

    }

    @GetMapping("/page")
    @ApiOperation("分页查询互动提问的问题")
   public PageDTO<QuestionVO> queryQuestionPage(QuestionPageQuery query ){
     return questionService.queryQuestionPage(query);
   }
   @GetMapping("/{id}")
   @ApiOperation("根据id查询互动提问的问题")
   public QuestionVO getQuestionById(@PathVariable Long id){
       return questionService.getQuestionById(id);
   }
   @DeleteMapping("/{id}")
   public void deleteQuestionById(@PathVariable Long id){
       questionService.deleteQuestionById(id);
   }
}
